package com.seo.proxy.context;

import java.nio.channels.SocketChannel;

import com.seo.proxy.ReadWriteBuffer;

public class ClientContext {

	private ReadWriteBuffer readWriteBuffer;

	private RequestContext requestContext;

	private ResponseContext responseContext;

	private int readWriteBufferSize;
	
	public ClientContext(SocketChannel requestSocketChannel, int readWriteBufferSize) {
		this.requestContext = new RequestContext(this, requestSocketChannel);
		this.readWriteBufferSize = readWriteBufferSize;
	}

	public RequestContext getRequestContext() {
		return requestContext;
	}

	public ResponseContext getResponseContext() {
		return responseContext;
	}

	public void setResponseContext(ResponseContext responseContext) {
		this.responseContext = responseContext;
	}

	public ReadWriteBuffer getReadWriteBuffer() {
		if (readWriteBuffer == null) {
			readWriteBuffer = new ReadWriteBuffer(readWriteBufferSize);
		}
		return readWriteBuffer;
	}

	public void reset() {
		requestContext.reset();
		responseContext = null;
	}
}
